<?php
session_start();

require_once(dirname(__FILE__) . '/config.php');
require_once(ABS_PATH . 'includes/classes/MockAuthenticationAdapter.php');
require_once(ABS_PATH . 'includes/classes/Authenticator.php');

if (!isset($_SESSION['loggedon']) || !$_SESSION['loggedon']){
	// redirect to login page
	header('Location: ' . LOGIN_URL);
}

// check to see if we've got a token from the login page
if (isset($_POST['token'])) {	
	$token = $_POST['token'];
	
	// now check with authenticator to see if the token provided is valid
	$authAdapter = new MockAuthenticationAdapter();
	$authenticator = new Authenticator($authAdapter);
	if (!$authenticator->isValidToken($token)) {
		// redirect to login page
		header('Location: ' . LOGIN_URL);
	}
} 

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<title>Lagrange CMS</title>
	
	<link rel="stylesheet" type="text/css" href="lib/ext-2.0/resources/css/ext-all.css" />    
	<link rel="stylesheet" type="text/css" href="app/resources/css/core.css" />	
</head>
<body>  
  	<div id="north">
		<p>north - generally for menus, toolbars and/or advertisements</p>
	</div>
	
	<div id="west">
		<p>Hi. I'm the west panel.</p>
	</div>
		
	<div id="startPageContent">
		<div style="float:right;">
			<img src="app/resources/images/logo_white_web_small.jpg" alt="Solidarity Systems" />
		</div>
		<h1>Welcome</h1>
		<br/>
		<p>Lagrange is a powerful yet simple application that allows <em>you</em> to regain control of your web site!</p>
		<ul>
			<li>
				Want to change the text on one of your pages, re-organise your site's menu, upload some pictures, or change 
				the a page's artwork? Just click on the "Site" button up the top of the screen to get started.<br/><br/>
			</li>
			<li>
				Need to upload some files that you want your audience to be able to view or download? Simply click the "Files"
				button to take you to your sites file manager.<br/><br/>
			</li>
			<li>
				Have you got a big site and want to delegate some of the responsibility of looking after it? Clicking the 
				"Users" button will take you to the user management suite where you can add, remove and assign responsibility 
				for pages to users.<br/><br/>
			</li>
		</ul>
	</div>
  
  	<div id="siteTreePanel"></div>
	
	<!-- ext libs -->
 	<script type="text/javascript" src="lib/ext-2.0/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="lib/ext-2.0/ext-all-debug.js"></script>	
	
	<!-- cmx libs -->	
	<script type="text/javascript" src="app/src/App.js"></script>
	<script type="text/javascript" src="app/src/tree/SiteTreePanel.js"></script>
	<script type="text/javascript" src="app/src/menu/MainMenu.js"></script>
	
	<script type="text/javascript">
		var app = new cmx.App();		
    	Ext.onReady(app.init, app);
	</script>
 </body>
</html>